package com.czk.springcloud.service;

import com.czk.springcloud.entity.CommonResult;
import com.czk.springcloud.entity.Payment;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/12/18 14:15
 */
@Service
@FeignClient(value = "CLOUD-PAYMENT-SERVICE", fallback = SentinelPaymentFeignServiceImpl.class)
public interface PaymentFeignService {
    /**
     * 读
     *
     * @param id
     * @return
     */
    @GetMapping("/payment/select/{id}")
    CommonResult<Payment> getPaymentById(@PathVariable("id") Long id);

    /**
     * 模拟feign超时接口
     *
     * @return
     */
    @GetMapping("/payment/feign/timeout")
    String paymentFeignTimeout();

    /**
     * 测试用feign调用时返回不封装数据，普通的http调用封装数据会返回
     *
     * @return
     */
    @GetMapping("/payment/test/feign")
    Payment payment();

    /**
     * 异常模拟
     *
     * @param accountCode
     * @return
     */
    @GetMapping("/payment/error/{accountCode}")
    Payment selectByCode(@PathVariable("accountCode") String accountCode);
}
